package com.juejin.www.dao;

import com.juejin.www.model.DO.BoilingPoint;
import com.juejin.www.model.DTO.BoilingPointDTO;
import org.apache.ibatis.annotations.*;
import java.util.List;

/**
 * @author Jacky
 */
@Mapper
public interface BoilingPointDao {

    /**
     * 获取沸点列表
     * @param begin 起始加载索引
     * @return 沸点列表
     */
    @Select("select * from boiling_points order by create_time desc limit #{begin},5")
    List<BoilingPoint> list(Integer begin);

    /**
     * 获取沸点总数
     * @return 沸点总数
     */
    @Select("select count(*) from boiling_points")
    int getTotalCount();

    /**
     * 发布沸点
     * @param boilingPointDTO 沸点实体
     */
    @Insert("insert into boiling_points(id, content, author_id, create_time, update_time, like_count, comment_count) " +
            "values (null,#{content},#{authorId},now(),now(),0,0)")
    void addBoilingPoint(BoilingPointDTO boilingPointDTO);

    /**
     * 删除沸点
     * @param id 沸点id
     */
    @Delete("delete from boiling_points where id=#{id}")
    void deleteBoilingPoint(Integer id);

}
